<template>
  <div class="loginForm">
    <div>
      <div class="group">
        <slot name="userIcon"></slot><input v-model="userForm.tel" type="text">
      </div>
      <div class="group">
        <slot name="passIcon"></slot><input v-model="userForm.password" type="password">
      </div>
      <div class="group submitButton"><input type="button" v-model="buttonTxt" @click="submit"></div>
      <slot></slot>
    </div>
  </div>
</template>

<script>
import { loginRequest } from '../../api/login'
export default {
  props: {
    url: String,
    buttonTxt: {
      type: String,
      default: ''
    },
    userForm: {
      type: Object,
      default: Object
    }
  },
  data() {
    return {
    }
  },
  methods: {
    async submit() {
      let res = await loginRequest(this.url, this.userForm)
      this.$emit('submit', res)
    }
  }
}
</script>

<style scoped>
.loginForm {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loginForm>div {
  flex: 1;
}

.loginForm .group {
  display: flex;
  margin: 20px 50px;
  border: 1px solid #ccc;
  height: 42px;
  align-items: center;
  padding: 0 10px;
}

.loginForm input {
  height: 42px;
  flex: 1;
  border: none;
  background: none;
  outline: none;
  padding-left: 10px;
}

.loginForm input[type=button] {
  background: #f06;
  color: #fff;
  border: none;
  padding: 0;
}

.loginForm .submitButton {
  border: none;
}
</style>